﻿#r @"..\Microsoft.SharePoint.Client (spo)\Microsoft.SharePoint.Client.dll"
#r @"..\Microsoft.SharePoint.Client (spo)\Microsoft.SharePoint.Client.Runtime.dll"
#r @"..\Microsoft.SharePoint.Client (spo)\Microsoft.SharePoint.Client.UserProfiles.dll"

#load "Client.fs"

open Client
open Microsoft.SharePoint.Client
open Microsoft.SharePoint.Client.Sharing
open Microsoft.SharePoint.Client.Utilities
open Microsoft.SharePoint.Client.WebParts
open Microsoft.SharePoint.Client.Application
open Microsoft.SharePoint.Client.UserProfiles
open System.Security;

// =======================================================
// Work with user profile and MySite
// =======================================================

let web = Client.Context.Web
Client.Load web

let loader = Microsoft.SharePoint.Client.UserProfiles.ProfileLoader.GetProfileLoader(Client.Context)

let profile = loader.GetUserProfile()
Client.Load profile
profile

let site = profile.PersonalSite
Client.Load site

profile.CreatePersonalSiteEnque()
Client.ExecuteQuery()
